package me.work.pay.jsyl.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.widget.Button;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import me.work.pay.jsyl.app.utils.SoundMaker;
import me.work.pay.jsyl.di.component.DaggerTestComponent;
import me.work.pay.jsyl.mvp.contract.TestContract;
import me.work.pay.jsyl.mvp.presenter.TestPresenter;

import me.work.pay.jsyl.R;


import static com.jess.arms.utils.Preconditions.checkNotNull;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 09/19/2020 20:10
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
public class TestActivity extends BaseActivity<TestPresenter> implements TestContract.View {

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerTestComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }

    ImageView iv11;

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_test; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    Button searchDivice;

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        iv11 = findViewById(R.id.iv11);
        Glide.with(this)
                .load("http://cmmerchant.congmingpay.com/7898ffe6550cc695ce6d31c248ced1a6/ad2.jpg").into(iv11);
        searchDivice = findViewById(R.id.searchDivice);
        searchDivice.setOnClickListener(v ->
        {
//            new SoundMaker(this).makeSound("1","123.23");
            new SoundMaker(this).makeSound("3", "1");

//            new Thread(new Runnable() {
//                public void run() {
//                    //sleep设置的是时长
//                    try {
//                        Thread.sleep(500);
//                        new SoundMaker(TestActivity.this).makeSound("sound1");
//                    } catch (InterruptedException e) {
//                        e.printStackTrace();
//                    }
//                }
//            }).start();
            //            new PlaySound().play(this, "200.01", "1");
        });
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }
}
